﻿using guanli.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using guanli.Entity;

namespace guanli.Controllers
{
    public class ZhuCeController : Controller
    {
        //
        // GET: /ZhuCe/
        public DataBase dataBase = new DataBase();

        public ActionResult Index()
        {
            Console.WriteLine("进来了注册的get函数");
            return View();
        }

        [HttpPost]
        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Index(UserRegister user)
        {
            /*这边要改造一下，现在的逻辑不是很通。*/
            Console.WriteLine("进来了注册的POST函数");
            if (dataBase.userPanDuan(user))
            {
             // 要执行注册账号的任务 
             dataBase.Add(user);
             ViewBag.Message = "注册成功";
            }
            else
            {
                ViewBag.Message = "该账号已存在";
            }
            // 这里写上一个已有账号
            return View();
        }

        [HttpPost]
        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Register(FormCollection f)
        {
            Console.WriteLine("Register");
            string zhanghao = f["username"];
            string mima = f["password"];

            // 处理注册逻辑
            Console.WriteLine($"帐号: {zhanghao}, 密码: {mima}");

            return View();
        }
    }
}